<%@ page contentType="text/html;charset=UTF-8"%>
<%@ include file="/common/taglibs.jsp"%>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>

<title>附件列表</title>
	<!-- 引入基础的JS和CSS文件 -->
	<link href="${ctx}/resources/css/aos/aos_${css}.css" rel="stylesheet" type="text/css"/>
	
	<%@ include file="/common/meta_ext.jsp"%>
	
	<script src="${ctx}/resources/js/aos/tool.js" type="text/javascript"></script>
	
	<script src="${ctx}/common/sysfile/public/attachment-operation.js" type="text/javascript"></script>
	<script src="${ctx}/resources/js/aos/ext_ux/BasicGrid.js" type="text/javascript"></script>
	
	
	<script type="text/javascript">
	
	Ext.onReady(function(){
		Ext.QuickTips.init();
		
		// 列表部分
		var gridStructure = [{  
			name: 'sysFileId',
			hidden: true
		},{  
			name: 'fileCode',  
			header: "附件编号",
			sortable: true,
			width: 140
		},{  
			name: 'fileName',  
			header: "附件名称",
			sortable: true,
			width: 200
		},{  
			name: 'fileType',  
			header: "附件类型",
			sortable: true,
			width: 100
		},{  
			name: 'fileFormat',  
			header: "附件格式",
			sortable: true,
			width: 100
		},{  
			name: 'filePath',  
			header: "附件路径",
			sortable: true,
			width: 200
		},{  
			name: 'cmp',  
			header: "创建人",
			sortable: true,
			width: 100
		},{  
			name: 'cdt',  
			header: "创建时间",
			sortable: true,
			type: 'datetime',
			width: 150
		},{  
			name: 'eemp',  
			header: "修改人",
			sortable: true,
			width: 100
		},{  
			name: 'edt',  
			header: "修改时间",
			sortable: true,
			type: 'datetime',
			width: 180
		},{
			name: 'sysFileId',
			header: "操作",
			width: 150,
			renderer: function(value, metaData, record, rowIndex, colIndex, store) {
        		var fileName = record.get('fileName');
        		var sysFileId = value;
        		
        		//对附件操作后跳转的url
        		var redirectUrl = "${ctx}/sysfile/sys-file!showAttachmentsIframe.action?entity=${entity}%26entityId=${entityId}";
				//删除附件的url
				var delUrl = '${ctx}/sysfile/sys-file!deleteAttachment.action?sysFileId=' + sysFileId;
				//下载或者读取附件的url
				var readUrl = '${ctx}/sysfile/sys-file!readAttachment.action?sysFileId=' + sysFileId;
				//用ntko控件编辑附件的url
				var editDocUrl = '${ctx}/sysfile/sys-file!editOfficeDoc.action?sysFileId=' + sysFileId;
				
				var btn1 = "<a onclick='readAttachment(\""+ readUrl + "\"" + ','+ "\"" + sysFileId +"\")' style=\"cursor:hand\"><img src=\"${ctx}/resources/images/icons/16_16/cart_put.png\" border=\"0\" alt=\"下载附件\"></a>";
				var btn2 = "<a onclick='deleteAttachment(\"" + fileName + "\"" + ','+ "\"" + delUrl + "\"" + "," + "\"" + redirectUrl + "\")' style=\"cursor:hand\"><img src=\"${ctx}/resources/images/icons/16_16/delete.gif\" border=\"0\" alt=\"删除附件\"></a>";
				var btn3 = "<a onclick='editOfficeDoc(\""+ editDocUrl + "\"" + "," + "\""+ sysFileId +"\"" + "," + "\"" + fileName+ "\")' style=\"cursor:hand\"><img src=\"${ctx}/resources/images/icons/16_16/book_edit.png\" border=\"0\" alt=\"在线编辑文档内容\"></a>";
				return btn1+"&nbsp;&nbsp;"+btn2+"&nbsp;&nbsp;"+btn3;
        	}
		}];
	   
		var grid = new Ext.ux.grid.BasicGrid({
			height: 200,
			title: '附件列表',
			id: 'attachmentGridPanel',
			margins: '0 1 1 1',
			structure: gridStructure,
			url: '${ctx}/sysfile/sys-file!list.action?entity=${entity}&entityId=${entityId}',
			defaultSortField: 'fileCode',  
			keyField: 'sysFileId',
			preload: true
		});
		
		grid.render('attachmentGrid');
	});
	</script>



</head>
<body>
	<form method='post' enctype="multipart/form-data">
	<table class="tb_custom">
		<tr>
			<td class="td_header_l" colspan="12">
				<table width="100%"><tr>
					<th width="5"></th>
					<th width="20"><img src="${ctx}/resources/images/icons/16_16/attach.png"/></th>
					<th align="left">附件管理</th>
				</tr></table>
			</td>
		</tr>
		<!----------------- 上传附件开始 ------------------->
		<tr>
			<td class="td_header_r" width="150">请选择要上传的附件：</td>
			<td class="td_header_l" colspan="11">
				<input type="file" name="attachment" size="80" style="height:95%"/>&nbsp;
				<input type="button" value="上传附件" onclick="addAttachment('${ctx}/sysfile/sys-file!addAttachment.action?entity=${entity}&entityId=${entityId}','${ctx}/sysfile/sys-file!showAttachmentsIframe.action?entity=${entity}%26entityId=${entityId}')"/>
				<input type="button" value="批量上传" onclick="openCenterWindow('${ctx}/resources/components/swfupload/swfupload.jsp?entity=${entity}&entityId=${entityId}', 700, 400)"/>
				<input type="button" value="删除附件" onclick="deleteAttachmentsIframe('${ctx}/sysfile/sys-file!deleteMoreAttachment.action','${ctx}/sysfile/sys-file!showAttachmentsIframe.action?entity=${entity}%26entityId=${entityId}')"/>
			</td>
		</tr>
		<!----------------- 上传附件结束 ------------------->
	</table>
	<div id="attachmentGrid"></div>
	</form>
</body>
</html>